/*
-----------------------------------------------------------------------------
This source file is part of DIVA
The project of Engineering Lab, dept. of CSIE, NTNU.

Copyright (c) 2000-2006 The Engineering Lab, dept. of CSIE, NTNU.
-----------------------------------------------------------------------------
Filename:    xNodeType_StringComposer.h
Description: 處理特定string的xNodeType。
Author: hyt
History:  hyt - 09/09/28 因應WOP_Int_Proxy而修改
-----------------------------------------------------------------------------
*/

#ifndef _H_xNodeType_StringComposer_H_
#define _H_xNodeType_StringComposer_H_

#include "xMappingNodeTypeLibrary.h"
#include <set>
typedef std::set<string> IndexCollect;

class xNodeType_StringComposer: public xNodeType {
	xParameterPack _xpp;
	WOP_Entry *	_wop ;
	xMappingTree _xmt;
	bool _haveString;
	string _customString;
public:
	xNodeType_StringComposer();
	virtual void setupPorts();
	virtual string getType() { return "string_composer";}
	virtual void createMappedObject();
	virtual xParameter toXParameter(string type, xOutMappingPort* linked_op); 
	virtual string toMDString(MDSType) ;
	virtual int     parseMDString(vector<string>& tokens, int start_index);
	virtual bool verify_rhs_link(xOutMappingPort *left, xInMappingPort *right, xNodeType* rightnode);
	virtual bool verify_lhs_link(xOutMappingPort *left, xNodeType* leftnode, xInMappingPort *right);
	virtual bool update();
	bool haveCustomString();
	string isStringValidate(string);
	string replaceSpace();
	string recoverSpace(string customstring);
	void removeCustomString();
	string getCustomString() { return _customString;};
	virtual ~xNodeType_StringComposer();
private:
	void splitString(string);
	IndexCollect index;
	string replaceCustomstring();
	static string valid_rhs_pair[][2];
	static string gate_pair[][2];
	static string wop_pair[][2];
	static string other_pair[][2];
};
#endif